class DimenTrunkGroupCarrier < ActiveRecord::Base
  has_many :fact_dest_trunk_groups
           #:class_name => "FactDestTrunkGroup",
           #:finder_sql => "select f.*, d.* from dimen_trunk_group_carriers d, fact_dest_trunk_groups f \ 
           #                   where f.dimen_trunk_group_carrier_id = d.id"
  belongs_to :dimen_dest_vcb
             #:class_name => DimenDestVcb,
             #:finder_sql => "select t.*, v.* from dimen_trunk_group_carriers t, dimen_dest_vcbs v \
             #                where t.dimen_dest_vcb_id=v.id" 
  def all_trunk_groups_filtered_by_date(from, to)
    self.find(:all, \
    :include    =>[:fact_dest_trunk_groups, :dimen_dest_vcb], \
    :conditions =>["fact_dest_trunk_groups.timestamp is null or (fact_dest_trunk_groups.timestamp>=? and fact_dest_trunk_groups.timestamp<?)", from, to], \
    :order      =>"identifying_phone_number, fact_dest_trunk_groups.timestamp ASC")
      #:group      =>"identifying_phone_number") does not work
  end
end
